<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    // 发起get请求
    const msg = {
        username:"admin",
        password:123456
    }
    const url = "http://localhost:3000/login" + "?" + queryParser(msg)

    fetch(url).then(res=>{
        console.log(res);
        return res.json()
    }).then(res=>{
        console.log(res.data)
        console.log(res.data.token);
    })

    // 发起post请求
    const data = {
        token:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1SWQiOiJ1c2VyLTE5NDI1ZGQwLThiZDgtMTFlZC1hMWYzLWRkOWZkODhmNTUxYyIsInVzZXJuYW1lIjoiYWRtaW4iLCJwb3dlciI6MCwiaWF0IjoxNjcyOTkxMjY0LCJleHAiOjE2NzI5OTMwNjR9.eB0DoChbJM4cZOGVJfMUqYjOseGw6-QEkplwL64Zedc"
    }
    const getmeetingroom = "http://localhost:3000/getallroom";
    fetch(getmeetingroom, {
        method:"POST",
        body:queryParser(data),
        headers:{
            "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
        }
    })
    .then(res=>res.json())
    .then(res=>{
        console.log(res)
    })



    function queryParser(obj){
        let str = "";
        for(let i in obj){
            str += `${i}=${obj[i]}&`
        }
        return str.slice(0,-1);
    }
    
</script>
</html>